#include<iostream>
#include<cstring>
using namespace std;

char num[240];
bool del[240];

int main() {
    int count;
    while(scanf("%s", &num) != EOF) {
        // string str = num;
        cin >> count;
        memset(del, false, sizeof(del));

//      特例处理
        if (count >= strlen(num)) {
            cout << -1 << endl;
            break;
        } else if (count == strlen(num)-1) {
            cout << "" <<endl;
            break;
        }

//      删数核心
        while(count--) {
            int len = strlen(num);
            char temp[240];
            for (int i=0; i<len; i++) {
                if (i == len-1 || num[i] > num[i+1]) {
                    for (int j=i+1; j<len; j++, i++) {
                        temp[i] = num[j];
                    }
                    break;
                }
                temp[i] = num[i];
            }
            for (int i=0; i<len-1; i++) {
                num[i] = temp[i];
            }
            num[len-1] = 0;
        }

//      输出
        bool flag = false;
        for(int i=0; i<strlen(num); i++) {
            if (num[i] == '0' && !flag)
                continue;
            cout << num[i];
            flag = true;
        }
        cout << endl;

        memset(num, 0, sizeof(num));
    }
    return 0;
}